package cc.yugu.yhdw.webserver.web.controller.security.basic;

import cc.yugu.yhdw.common.annotation.ViewModel;
import cc.yugu.yhdw.common.domain.basic.AppGrade;
import cc.yugu.yhdw.common.entity.json.ExtResult;
import cc.yugu.yhdw.common.entity.json.PageResult;
import cc.yugu.yhdw.webserver.constant.AppConstEnum;
import cc.yugu.yhdw.webserver.service.basic.AppGradeService;
import cc.yugu.yhdw.webserver.web.controller.security.SecurityController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户反馈控制器
 * 
 * @Date:Created in 2018/7/17 11:33
 * @Author:
 * @Modified By: zjn 2018/7/17 11:33
 */ 
@Controller
@RequestMapping(value = "/security/basic/app_grade")
public class AppGradeController extends SecurityController {
    @Autowired
    AppGradeService appGradeService;


    @RequestMapping("index.htm")
    public void index(Model model) {
        model.addAttribute(MENU_CODE_NAME, AppConstEnum.Menu.MENU_06_03.getValue());
    }
    /**
    * 分页查询用户反馈信息
    * 
    * @Param: [search]
    * @Return: cc.yugu.yhdw.common.entity.json.PageResult
    * @Author By: zjn 2018/7/17  11:33
    */ 
    @RequestMapping("page.htm")
    @ViewModel(ViewModel.JSON)
    @ResponseBody
    public PageResult page( AppGrade search) {
        return PageResult.successResult(appGradeService.findPage(search));
    }
    /**
    * 前台显示用户反馈信息
    * 
    * @Param: [id, model]
    * @Return: java.lang.String
    * @Author By: zjn 2018/7/17  11:34
    */ 
    @ViewModel(ViewModel.INNER_PAGE)
    @RequestMapping("view.htm")
    public String view(int id, Model model) {
        AppGrade appGrade = appGradeService.find(id);
        if(appGrade == null) {
            return SEGMENT_RECORD_NOT_FOUND;
        }
        model.addAttribute("entity", appGrade);
        return "/security/basic/app_grade/view";
    }
    /**
    * 删除
    * 
    * @Param: [id]
    * @Return: cc.yugu.yhdw.common.entity.json.ExtResult
    * @Author By: zjn 2018/7/17  11:34
    */ 
    @RequestMapping("delete.htm")
    @ViewModel(ViewModel.JSON)
    @ResponseBody
    public ExtResult delete(int id) {
        appGradeService.delete(id);
        return ExtResult.successResult();
    }

}
